//
//  OrderManageCell.m
//  SameWorld(merchant)
//
//  Created by 李小朋 on 2017/3/31.
//  Copyright © 2017年 杨旭. All rights reserved.
//

#import "OrderManageCell.h"
#import "OrderModel.h"
#import "OrderCommodityModel.h"
#import <UIImageView+WebCache.h>
@interface OrderManageCell ()

// ** 订单编号*/
@property (weak, nonatomic) IBOutlet UILabel *order_idLabel;
// ** 用户头像*/
@property (weak, nonatomic) IBOutlet UIImageView *userPictureImage;
// ** 用户名称*/
@property (weak, nonatomic) IBOutlet UILabel *userNameLabl;
// ** 时间*/
@property (weak, nonatomic) IBOutlet UILabel *timeLabl;
// ** 商品图片*/
@property (weak, nonatomic) IBOutlet UIImageView *shopPictureImage;
// ** 名称*/
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
// ** 开始时间*/
@property (weak, nonatomic) IBOutlet UILabel *starTimeLabel;
// ** 单价*/
@property (weak, nonatomic) IBOutlet UILabel *singlePrice;
// ** 总价*/
@property (weak, nonatomic) IBOutlet UILabel *totalPrice;

@end

@implementation OrderManageCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.userPictureImage.layer.masksToBounds = YES;
    self.userPictureImage.layer.cornerRadius = self.userPictureImage.frame.size.width/2;
    self.userPictureImage.layer.borderWidth = 1;
    self.userPictureImage.layer.borderColor = [UIColor colorWithHexString:@"#dddddd"].CGColor;
}

- (void)setUpDataWithOrderModel:(OrderModel *)model withType:(NSString *)type {

    // 展示订单编号
    self.order_idLabel.text = [NSString stringWithFormat:@"订单编号:%@",model.order_id];
    // 展示时间
    self.timeLabl.text = [NSString stringWithFormat:@"%@",model.start_sj];
    // 展示用户名称
    self.userNameLabl.text = [model.userrows objectForKey:@"yhm"];;
    // 展示用户头像
    NSString *urlStr = [NSString stringWithFormat:@"%@%@",url_Base,[model.userrows objectForKey:@"img"]];
    [self.userPictureImage sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:[UIImage imageNamed:@"占位图-1"]];
    // 单价
    self.singlePrice.text = [NSString stringWithFormat:@"¥%@x%@",model.actual_je,model.Number];
    
    if ([type isEqualToString:@"9"]) {
        [self.orderTypeBtn setTitle:@"订单关闭" forState:(UIControlStateNormal)];
    }else if ([type isEqualToString:@"0"]) {
        [self.orderTypeBtn setTitle:@"待支付" forState:(UIControlStateNormal)];
    }else if ([type isEqualToString:@"1"]) {
        [self.orderTypeBtn setTitle:@"未使用" forState:(UIControlStateNormal)];
    }else if ([type isEqualToString:@"2"]) {
        [self.orderTypeBtn setTitle:@"待评价" forState:(UIControlStateNormal)];
    }else if ([type isEqualToString:@"3"]) {
        [self.orderTypeBtn setTitle:@"退款" forState:(UIControlStateNormal)];
    }
    
  
}

- (void)setUpDataWtihrderCommodityModel:(OrderCommodityModel *)model {

    // 商品名称
    self.titleLabel.text = [NSString stringWithFormat:@"%@",model.title];
    // 商品图片
    NSString *urlStr = [NSString stringWithFormat:@"%@%@",url_Base,model.app_home_img];
    [self.shopPictureImage sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:[UIImage imageNamed:@"占位图-1"]];
    // 商品结算价格
    self.totalPrice.text = [NSString stringWithFormat:@"总价%@",model.settlenment];
}

@end
